]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
messageList: Make media messages follow notification policy
authorFlorian Müllner <fmuellner@gnome.org>
Wed, 1 Oct 2025 18:19:14 +0000 (20:19 +0200)
committerMarge Bot <marge-bot@gnome.org>
Tue, 14 Oct 2025 20:22:58 +0000 (20:22 +0000)
Unlike regular notifications, media messages are shown unconditionally
for any active MPRIS player. In the past that was uncontroversial, but
now that media messages are shown on the lock screen as well, there is
a privacy concern.

To address this, make media messages follow the notification policy
of the corresponding app (if specified) or the general notification
settings.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/8600
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3896>

js/ui/messageList.js

index 265d7a3f95b1bd2660da7ffb9505a3a698a95220..ee4f7e258f73f789e25e844f1816ab084d9cc798 100644 (file)
@@ -793,6 +793,8 @@ class MediaMessage extends Message {
                 this._player.next();
             });
 
+        Main.sessionMode.connectObject('updated',
+            () => this._applyPolicy(), this);
         this._player.connectObject('changed', this._update.bind(this), this);
         this._update();
     }
@@ -805,6 +807,12 @@ class MediaMessage extends Message {
         Main.panel.closeCalendar();
     }
 
+    _applyPolicy() {
+        this.visible =
+            this._policy.enable &&
+            (!Main.sessionMode.isLocked || this._policy.showInLockScreen);
+    }
+
     _updateNavButton(button, sensitive) {
         button.reactive = sensitive;
     }
@@ -832,6 +840,22 @@ class MediaMessage extends Message {
 
         this._updateNavButton(this._prevButton, this._player.canGoPrevious);
         this._updateNavButton(this._nextButton, this._player.canGoNext);
+
+        const appId = this._player.app?.id.replace(/\.desktop$/, '');
+        if (this._policy?.id !== appId) {
+            this._policy?.disconnectObject(this);
+
+            this._policy = MessageTray.NotificationPolicy.newForApp(this._player.app);
+
+            // Register notification source
+            this._policy.store();
+
+            this._policy.connectObject(
+                'notify::enable', () => this._applyPolicy(),
+                'notify::show-in-lock-screen', () => this._applyPolicy(),
+                this);
+            this._applyPolicy();
+        }
     }
 });